import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'
import '@arco-design/web-react/dist/css/arco.css'
import ProtectedRoute from './components/ProtectedRoute'
import MainLayout from './components/Layout/MainLayout'
import Login from './pages/Auth/Login'
import Dashboard from './pages/Dashboard'
import Workflow from './pages/Workflow'
import WorkflowEditor from './pages/WorkflowEditor'
import Pipeline from './pages/Pipeline'
import PipelineHistory from './pages/PipelineHistory'
import Task from './pages/Task'
import TaskDetail from './pages/TaskDetail'
import Node from './pages/Node'
import LogManagement from './pages/LogManagement'
import Settings from './pages/Settings'

function App() {
  return (
    <BrowserRouter>
      <Routes>
        {/* 公开路由 */}
        <Route path="/login" element={<Login />} />

        {/* 受保护的路由 */}
        <Route
          path="/"
          element={
            <ProtectedRoute>
              <MainLayout />
            </ProtectedRoute>
          }
        >
          {/* 仪表盘 */}
          <Route index element={<Dashboard />} />

          {/* 工作流管理 */}
          <Route path="workflow" element={<Workflow />} />
          <Route path="workflow/:id/edit" element={<WorkflowEditor />} />

          {/* 流水线管理 */}
          <Route path="pipeline" element={<Pipeline />} />
          <Route path="pipeline/:id/history" element={<PipelineHistory />} />

          {/* 任务监控 */}
          <Route path="task" element={<Task />} />
          <Route path="task/instance/:id" element={<TaskDetail />} />

          {/* 节点管理 */}
          <Route path="node" element={<Node />} />

          {/* 日志管理 */}
          <Route path="logs" element={<LogManagement />} />

          {/* 系统设置 */}
          <Route path="settings" element={<Settings />} />
        </Route>

        {/* 404 重定向 */}
        <Route path="*" element={<Navigate to="/" replace />} />
      </Routes>
    </BrowserRouter>
  )
}

export default App
